package com.heyou.controller;

import com.heyou.assistant.HeyouAgent;
import com.heyou.pojo.ChatFormVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Tag(name = "禾优小智")
@RestController
@RequestMapping("/heyou")
public class HeyouController {

    @Autowired
    HeyouAgent heyouAgent;

    /**
     * 对话
     * @param chatFormVO 表单信息
     * @return 响应信息
     */
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatFormVO chatFormVO) {
        return heyouAgent.chat(chatFormVO.getMemoryId(), chatFormVO.getMessage());
    }
}
